<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">评论审核</ui:define>
    <ui:define name="content">

        <h:form>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix" style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton value="批量模式"
                                         icon="fa fa-list-ul"
                                         actionListener="#{icpWebCommentBean.changeModeToBatch}"
                                         update="@form"
                                         process="@this"
                                         rendered="#{icpWebCommentBean.isNotBatch()}"/>

                        <p:commandButton value="常规模式" icon="fa fa-file"
                                         actionListener="#{icpWebCommentBean.changeModeToNormal}"
                                         process="@this"
                                         update="@form"
                                         rendered="#{icpWebCommentBean.isBatch()}"/>

                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"/>

                        <p:columnToggler datasource="commentDataTable" trigger="toggler"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         rendered="#{icpWebCommentBean.isNormal()}"
                                         update="@form"/>
                        <p:commandButton value="发布" icon="fa fa-eye"
                                         rendered="#{icpWebCommentBean.isBatch()}"
                                         actionListener="#{icpWebCommentBean.onBatchPublish()}"
                                         update="@form"/>
                        <p:commandButton value="删除" icon="fa fa-times"
                                         rendered="#{icpWebCommentBean.isBatch()}"
                                         actionListener="#{icpWebCommentBean.onBatchDelete()}"
                                         update="@form"/>
                        <p:commandButton value="重置" icon="fa fa-refresh"
                                         rendered="#{icpWebCommentBean.isNormal()}"
                                         actionListener="#{icpWebCommentBean.onReset}"
                                         process="@this" update="@form"/>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card">
                            <h1>查询条件</h1>
                            <p:panelGrid columns="8" layout="grid"
                                         columnClasses="ui-grid-col-1,ui-grid-col-2"
                                         styleClass="ui-panelgrid-blank"
                                         style="border:0px none; background-color:transparent;text-align:center;">
                                <p:outputLabel for="startTime" value="开始时间"/>
                                <p:calendar id="startTime" value="#{icpWebCommentBean.$.startTime}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATETIME_FORMAT')}"/>
                                <p:outputLabel for="endTime" value="结束时间"/>
                                <p:calendar id="endTime" value="#{icpWebCommentBean.$.endTime}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATETIME_FORMAT')}"/>
                                <p:outputLabel for="productName" value="文章标题"/>
                                <p:inputText id="productName" value="#{icpWebCommentBean.$.productName}"/>

                                <p:outputLabel for="userName" value="用户昵称"/>
                                <p:inputText id="userName" value="#{icpWebCommentBean.$.userName}"/>
                            </p:panelGrid>
                        </div>
                        <div class="card">
                            <p:dataTable id="commentDataTable"
                                         style="width: 100%;text-align:center"
                                         var="comment"
                                         value="#{icpWebCommentBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         reflow="true"
                                         selection="#{icpWebCommentBean.selectedRecords}"
                                         resizableColumns="true">

                                <p:column headerText="操作" style="width:70px;" rendered="#{icpWebCommentBean.isNotBatch()}">
                                    <p:splitButton icon="#{comment.getIcon()}"
                                                   process="@this" update="@form">
                                        <p:menuitem value="发布" icon="fa fa-eye"
                                                    actionListener="#{icpWebCommentBean.onPublish(comment.pk)}"
                                                    disabled="#{comment.isPublish() or !comment.isEnable()}"
                                                    process="@this" update="@form"/>
                                        <p:menuitem value="删除" icon="fa fa-times"
                                                    actionListener="#{icpWebCommentBean.onDelete(comment.pk)}"
                                                    disabled="#{!comment.isEnable() or !comment.isPublish()}"
                                                    process="@this" update="@form"/>
                                    </p:splitButton>
                                </p:column>
                                <p:column selectionMode="multiple" style="width:16px;text-align:center"
                                          rendered="#{icpWebCommentBean.isBatch()}"/>
                                <p:column headerText="发布时间">
                                    <h:outputText value="#{comment.createTime}"/>
                                </p:column>
                                <p:column headerText="文章标题" style="text-align:center;">
                                    <h:outputText value="#{comment.productName}"/>
                                </p:column>
                                <p:column headerText="用户昵称" style="text-align:center;">
                                    <h:outputText value="#{comment.userName}"/>
                                </p:column>
                                <p:column headerText="评论内容" style="width:500px;text-align:left;">
                                    <h:outputText value="#{comment.content}"/>
                                </p:column>
                                <p:column headerText="状态">
                                    <h:outputText value="#{comment.getStatusStr()}"/>
                                </p:column>
                                <p:column headerText="删除状态">
                                    <h:outputText value="#{comment.isEnableStr()}"/>
                                </p:column>
                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
